################################################################################
#
# recalbox-romfs-mame
#
################################################################################

# Package generated with :
# ./scripts/linux/empack.py --force --system mame --extension '.zip .ZIP' --fullname 'Mame' --platform arcade --theme mame 2:libretro:mame2003:BR2_PACKAGE_LIBRETRO_MAME2003 3:libretro:mame2000:BR2_PACKAGE_LIBRETRO_MAME2000 7:advancemame:advancemame:BR2_PACKAGE_ADVANCEMAME 4:libretro:mame2010:BR2_PACKAGE_LIBRETRO_MAME2010 5:libretro:mame2015:BR2_PACKAGE_LIBRETRO_MAME2015 6:libretro:mame2016:BR2_PACKAGE_LIBRETRO_MAME2016 1:libretro:mame2003_plus:BR2_PACKAGE_LIBRETRO_MAME2003_PLUS

# Name the 3 vars as the package requires
RECALBOX_ROMFS_MAME_SOURCE = 
RECALBOX_ROMFS_MAME_SITE = 
RECALBOX_ROMFS_MAME_INSTALL_STAGING = NO
# Set the system name
SYSTEM_NAME_MAME = mame
SYSTEM_XML_MAME = $(@D)/$(SYSTEM_NAME_MAME).xml
# System rom path
SOURCE_ROMDIR_MAME = $(RECALBOX_ROMFS_MAME_PKGDIR)/roms

# CONFIGGEN_STD_CMD is defined in recalbox-romfs, so take good care that
# variables are global across buildroot


ifneq ($(BR2_PACKAGE_LIBRETRO_MAME2003)$(BR2_PACKAGE_LIBRETRO_MAME2000)$(BR2_PACKAGE_ADVANCEMAME)$(BR2_PACKAGE_LIBRETRO_MAME2010)$(BR2_PACKAGE_LIBRETRO_MAME2015)$(BR2_PACKAGE_LIBRETRO_MAME2016)$(BR2_PACKAGE_LIBRETRO_MAME2003_PLUS),)
define CONFIGURE_MAIN_MAME_START
	$(call RECALBOX_ROMFS_CALL_ADD_SYSTEM,$(SYSTEM_XML_MAME),Mame,$(SYSTEM_NAME_MAME),.zip .ZIP,arcade,mame)
endef

ifneq ($(BR2_PACKAGE_LIBRETRO_MAME2003)$(BR2_PACKAGE_LIBRETRO_MAME2000)$(BR2_PACKAGE_ADVANCEMAME)$(BR2_PACKAGE_LIBRETRO_MAME2010)$(BR2_PACKAGE_LIBRETRO_MAME2015)$(BR2_PACKAGE_LIBRETRO_MAME2016)$(BR2_PACKAGE_LIBRETRO_MAME2003_PLUS),)
define CONFIGURE_MAME_LIBRETRO_START
	$(call RECALBOX_ROMFS_CALL_START_EMULATOR,$(SYSTEM_XML_MAME),libretro)
endef
ifeq ($(BR2_PACKAGE_LIBRETRO_MAME2003),y)
define CONFIGURE_MAME_LIBRETRO_MAME2003_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_MAME),mame2003,2)
endef
endif

ifeq ($(BR2_PACKAGE_LIBRETRO_MAME2000),y)
define CONFIGURE_MAME_LIBRETRO_MAME2000_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_MAME),mame2000,3)
endef
endif

ifeq ($(BR2_PACKAGE_LIBRETRO_MAME2003_PLUS),y)
define CONFIGURE_MAME_LIBRETRO_MAME2003_PLUS_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_MAME),mame2003_plus,1)
endef
endif

ifeq ($(BR2_PACKAGE_LIBRETRO_MAME2010),y)
define CONFIGURE_MAME_LIBRETRO_MAME2010_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_MAME),mame2010,4)
endef
endif

ifeq ($(BR2_PACKAGE_LIBRETRO_MAME2015),y)
define CONFIGURE_MAME_LIBRETRO_MAME2015_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_MAME),mame2015,5)
endef
endif

ifeq ($(BR2_PACKAGE_LIBRETRO_MAME2016),y)
define CONFIGURE_MAME_LIBRETRO_MAME2016_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_MAME),mame2016,6)
endef
endif

define CONFIGURE_MAME_LIBRETRO_END
	$(call RECALBOX_ROMFS_CALL_END_EMULATOR,$(SYSTEM_XML_MAME))
endef
endif

ifneq ($(BR2_PACKAGE_LIBRETRO_MAME2003)$(BR2_PACKAGE_LIBRETRO_MAME2000)$(BR2_PACKAGE_ADVANCEMAME)$(BR2_PACKAGE_LIBRETRO_MAME2010)$(BR2_PACKAGE_LIBRETRO_MAME2015)$(BR2_PACKAGE_LIBRETRO_MAME2016)$(BR2_PACKAGE_LIBRETRO_MAME2003_PLUS),)
define CONFIGURE_MAME_ADVANCEMAME_START
	$(call RECALBOX_ROMFS_CALL_START_EMULATOR,$(SYSTEM_XML_MAME),advancemame)
endef
ifeq ($(BR2_PACKAGE_ADVANCEMAME),y)
define CONFIGURE_MAME_ADVANCEMAME_ADVANCEMAME_DEF
	$(call RECALBOX_ROMFS_CALL_ADD_CORE,$(SYSTEM_XML_MAME),advancemame,7)
endef
endif

define CONFIGURE_MAME_ADVANCEMAME_END
	$(call RECALBOX_ROMFS_CALL_END_EMULATOR,$(SYSTEM_XML_MAME))
endef
endif



define CONFIGURE_MAIN_MAME_END
	$(call RECALBOX_ROMFS_CALL_END_SYSTEM,$(SYSTEM_XML_MAME),$(SOURCE_ROMDIR_MAME),$(@D))
endef
endif

define RECALBOX_ROMFS_MAME_CONFIGURE_CMDS
	$(CONFIGURE_MAIN_MAME_START)
	$(CONFIGURE_MAME_LIBRETRO_START)
	$(CONFIGURE_MAME_LIBRETRO_MAME2003_DEF)
	$(CONFIGURE_MAME_LIBRETRO_MAME2000_DEF)
	$(CONFIGURE_MAME_LIBRETRO_MAME2003_PLUS_DEF)
	$(CONFIGURE_MAME_LIBRETRO_MAME2010_DEF)
	$(CONFIGURE_MAME_LIBRETRO_MAME2015_DEF)
	$(CONFIGURE_MAME_LIBRETRO_MAME2016_DEF)
	$(CONFIGURE_MAME_LIBRETRO_END)
	$(CONFIGURE_MAME_ADVANCEMAME_START)
	$(CONFIGURE_MAME_ADVANCEMAME_ADVANCEMAME_DEF)
	$(CONFIGURE_MAME_ADVANCEMAME_END)
	$(CONFIGURE_MAIN_MAME_END)
endef

$(eval $(generic-package))
